1 00:00:00,740 --> 00:00:03,440 All right, so today I'm going to introduce variables. 2 00:00:03,440 --> 00:00:06,530 So I have my first game right here. 3 00:00:06,530 --> 00:00:08,420 I have my part right here. 4 00:00:08,420 --> 00:00:11,780 And then I have this printed script for my last video. 5 00:00:11,810 --> 00:00:14,510 I'm going to select that and turn this off. 6 00:00:14,510 --> 00:00:15,770 I'm going to disable it. 7 00:00:15,770 --> 00:00:20,540 So as disabled, click it and now it's disabled, it won't run. 8 00:00:20,540 --> 00:00:21,830 You see how gray it is. 9 00:00:22,010 --> 00:00:24,650 Let's go ahead and add another script. 10 00:00:24,650 --> 00:00:28,070 Click my part, plus sign script. 11 00:00:28,070 --> 00:00:30,590 And this one is going to be variables. 12 00:00:32,810 --> 00:00:34,820 I spelled the wrong variables. 13 00:00:34,820 --> 00:00:35,720 There we go. 14 00:00:35,720 --> 00:00:42,590 And now let me read off the computer science definition of variable so that it's formal variables are 15 00:00:42,590 --> 00:00:48,200 used to label and store data in memory so your program can use it. 16 00:00:48,230 --> 00:00:53,030 Let's just go ahead and see how it's done because you don't really need to know the definition in order 17 00:00:53,030 --> 00:00:55,040 how to in order to know how to use it. 18 00:00:55,130 --> 00:00:56,930 So I just got rid of that print statement. 19 00:00:56,930 --> 00:00:57,830 We don't need it. 20 00:00:58,010 --> 00:01:01,100 And now we're going to declare a variable. 21 00:01:01,100 --> 00:01:02,120 That's what it's called. 22 00:01:02,120 --> 00:01:04,970 When you add a variable to your program, you're declaring it. 23 00:01:05,210 --> 00:01:09,740 I'm going to say local file equals five, right? 24 00:01:09,740 --> 00:01:12,770 So local is a scope modifier. 25 00:01:12,770 --> 00:01:15,080 It says, where can I use this variable? 26 00:01:15,410 --> 00:01:18,650 We're going to be local, local to this script in this case. 27 00:01:18,980 --> 00:01:22,730 And then this is the name of the variable I decided to call it. 28 00:01:22,730 --> 00:01:26,180 Now you can call it what you want, but it should make sense. 29 00:01:26,480 --> 00:01:31,520 And then we're going to assign five, so we're going to give it the number five. 30 00:01:31,580 --> 00:01:37,670 So from here on out right now that Val is worth five. 31 00:01:38,030 --> 00:01:40,520 All right, let's do another let's do another variable. 32 00:01:41,060 --> 00:01:44,030 Local will say word. 33 00:01:44,420 --> 00:01:46,520 We're going to do a string data type. 34 00:01:46,520 --> 00:01:48,350 This is a number data type. 35 00:01:48,350 --> 00:01:49,490 Let's do a string. 36 00:01:50,030 --> 00:01:51,590 We kind of know what strings are. 37 00:01:51,620 --> 00:01:55,580 We need these speech quotes and then we'll do characters inside. 38 00:01:56,330 --> 00:02:03,230 Yea that's a string and it's also a word which is very descriptive for our variable. 39 00:02:04,670 --> 00:02:06,110 All right, let's do something else. 40 00:02:06,170 --> 00:02:08,900 I'm going to do a Boolean data type. 41 00:02:08,900 --> 00:02:11,740 Boolean means it could be true or false, right? 42 00:02:11,750 --> 00:02:12,140 That's it. 43 00:02:12,140 --> 00:02:12,760 True or false? 44 00:02:12,770 --> 00:02:13,340 It's a guy. 45 00:02:13,340 --> 00:02:16,310 A guy named George Boole came up with this type of logic. 46 00:02:16,310 --> 00:02:20,900 So it doesn't mean like to in Spanish or anything, it just means his name. 47 00:02:20,900 --> 00:02:24,230 So we'll say Can Touch is going to be a boolean data type. 48 00:02:24,230 --> 00:02:25,850 So it could be true or false? 49 00:02:26,510 --> 00:02:27,140 True. 50 00:02:27,530 --> 00:02:28,130 There we go. 51 00:02:28,130 --> 00:02:30,110 Maybe like a a coin or something. 52 00:02:30,110 --> 00:02:35,210 And you can touch it at a certain point of time and it'll be true and then we'll use that. 53 00:02:35,210 --> 00:02:37,970 Fi All right, let's print these values out. 54 00:02:38,540 --> 00:02:40,490 Print these variables out, I should say. 55 00:02:40,610 --> 00:02:45,500 So we have the value of VAO. 56 00:02:45,530 --> 00:02:47,870 We know how to do that from the last video. 57 00:02:47,870 --> 00:02:53,000 We also know that you can comma to limit stuff in the print statement and that will print out. 58 00:02:53,000 --> 00:02:58,910 Also, we can just put the name of the variable Val and it'll print out a five there. 59 00:02:59,540 --> 00:03:08,060 Print will say the word of the day equals say a word. 60 00:03:10,010 --> 00:03:13,550 And then let's do one for can touch. 61 00:03:13,880 --> 00:03:17,930 Can touch is enabled. 62 00:03:19,600 --> 00:03:20,340 Guys pretty cool. 63 00:03:20,350 --> 00:03:22,420 You actually don't have to put that space there. 64 00:03:22,720 --> 00:03:29,980 Roblox is pretty friendly and will add spacing in between whatever is common, too limited for readability 65 00:03:29,980 --> 00:03:33,740 so we can say can touch sweet. 66 00:03:33,790 --> 00:03:35,200 Let's go ahead and print this out. 67 00:03:37,060 --> 00:03:38,230 So it's a play. 68 00:03:38,260 --> 00:03:39,070 There we go. 69 00:03:39,100 --> 00:03:41,710 The value of value is five. 70 00:03:41,740 --> 00:03:43,640 The word of the day is eight. 71 00:03:43,720 --> 00:03:47,080 Can touch, is enabled, is true. 72 00:03:47,590 --> 00:03:48,520 Cool. 73 00:03:48,670 --> 00:03:49,390 All right. 74 00:03:49,390 --> 00:03:56,080 Now, because this is called a variable, you might suspect there's some sort of flexibility in it. 75 00:03:56,080 --> 00:03:57,420 And you can change it. 76 00:03:57,430 --> 00:03:58,380 You can. 77 00:03:58,390 --> 00:03:59,440 You would be right. 78 00:03:59,620 --> 00:04:01,750 Let's go ahead and get rid of this so we have more room. 79 00:04:02,410 --> 00:04:03,160 There we go. 80 00:04:03,400 --> 00:04:03,930 All right. 81 00:04:03,940 --> 00:04:05,740 Let's go ahead and change. 82 00:04:05,740 --> 00:04:07,440 Vow to ten. 83 00:04:07,450 --> 00:04:10,680 Notice I didn't need local because it's already been declared. 84 00:04:10,690 --> 00:04:15,850 We're just reassigning ten to the variable valve. 85 00:04:16,090 --> 00:04:17,500 Now word. 86 00:04:18,070 --> 00:04:24,010 Let's get something else something cool that young people say, I don't know cap. 87 00:04:24,280 --> 00:04:24,700 Right. 88 00:04:24,700 --> 00:04:30,670 They say stuff like that and now I'll say can touch the only thing it could be is false or true. 89 00:04:30,670 --> 00:04:30,940 Right? 90 00:04:30,940 --> 00:04:32,020 So it was true. 91 00:04:32,050 --> 00:04:34,810 We can make a false or we could be tricky. 92 00:04:34,810 --> 00:04:39,460 We could say not can touch, right? 93 00:04:39,730 --> 00:04:41,560 If can only be two things. 94 00:04:41,560 --> 00:04:44,950 If you put not in front of it, it'll be the other thing. 95 00:04:44,950 --> 00:04:46,690 So now that'll be false. 96 00:04:47,230 --> 00:04:48,370 Let's print stuff out. 97 00:04:48,370 --> 00:04:49,450 I'm just going to copy this. 98 00:04:49,450 --> 00:04:58,690 I'm going to highlight all that right click copy or control C come down here, right click paste. 99 00:04:59,140 --> 00:05:00,010 Cool. 100 00:05:00,040 --> 00:05:01,840 All right, now I have two listings. 101 00:05:01,840 --> 00:05:05,170 One of the old values, one of the new values or one of the first values. 102 00:05:05,170 --> 00:05:06,370 One with the second values. 103 00:05:06,760 --> 00:05:07,540 We can't see it. 104 00:05:07,540 --> 00:05:11,710 We need our output window view output. 105 00:05:12,490 --> 00:05:13,030 Cool. 106 00:05:13,120 --> 00:05:14,110 There's a lot there. 107 00:05:14,410 --> 00:05:14,740 There we go. 108 00:05:14,800 --> 00:05:15,700 Just pull that up. 109 00:05:15,910 --> 00:05:21,780 Says the value of vows five or the days you eat and then enabled can't touch as enabled is true. 110 00:05:21,790 --> 00:05:23,350 And then we changed our stuff. 111 00:05:23,350 --> 00:05:25,720 So now we have our ten, we have our cap. 112 00:05:25,720 --> 00:05:26,710 Look at that. 113 00:05:26,830 --> 00:05:27,610 False. 114 00:05:27,610 --> 00:05:33,070 So when we said not can touch and it was true, it flipped it to false. 115 00:05:34,570 --> 00:05:40,060 And yes, you could do not not and that would and that would change it back the true. 116 00:05:40,060 --> 00:05:43,420 But you don't want to have anything too tricky in your code. 117 00:05:44,020 --> 00:05:44,440 All right. 118 00:05:44,440 --> 00:05:46,810 So that will do it for today. 119 00:05:46,810 --> 00:05:49,200 Just a basic introduction of variables. 120 00:05:49,210 --> 00:05:50,440 Next video. 121 00:05:50,440 --> 00:05:55,330 We are going to get parts like my part and we're going to start working with the properties. 122 00:05:55,330 --> 00:05:59,800 We're going to assign that to a variable and some of the part properties, the variables. 123 00:05:59,800 --> 00:06:01,110 That's going to be fun. 124 00:06:01,120 --> 00:06:03,250 I will see you in the next video.